<?php
/**
 * 分类管理
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-6-17
 * Time: 下午2:37
 */
namespace app\modules\cn\controllers;

use app\libs\IeltsController;
use yii;
use app\modules\cn\models\Info;
use app\modules\content\models\Active;
use app\modules\content\models\Banner;
use app\modules\content\models\Calendar;
use app\modules\content\models\Classes;
use app\modules\content\models\Examroom;
use app\modules\content\models\Recommend;

class ExamroomController extends IeltsController
{
    public $enableCsrfValidation = false;
    public $layout = 'cn';

    /**
     * [actionIndex 考点列表]
     * @Author don
     * @Date   2021-11-01
     * @return [type]     [description]
     */
    public function actionIndex()
    {
        $data[0]=Examroom::getExamroom(0);//全部
        $data[1]=Examroom::getExamroom(1);//华东
        $data[2]=Examroom::getExamroom(2);//华南
        $data[3]=Examroom::getExamroom(3);//华中
        $data[4]=Examroom::getExamroom(4);//华北
        $data[5]=Examroom::getExamroom(5);//西北
        $data[6]=Examroom::getExamroom(6);//西南
        $data[7]=Examroom::getExamroom(7);//东北
        $time = time();
        $recommend = Info::find()->asArray()->where('cate=2 and pushTime<=' . $time)->orderBy('sort asc,id desc')->limit(4)->all();
        $course = Classes::find()->asArray()->limit(3)->orderBy('viewCount desc')->all();
        $focus = Recommend::find()->asArray()->where('type=2')->orderBy('sort asc,id desc')->limit(8)->all();
        $examInfo = Info::find()->asArray()->where('cate=4 and pushTime<=' . $time)->orderBy('sort asc,id desc')->limit(4)->all();
        $this->title = '申友雅思在线_考试地点';
        $this->keywords = '考试地点查询,考位资讯';
        $this->description = '申友雅思为考生提供最新最全的考位资讯，考点信息，满足考生各种阶段备考需求，只为雅思提分，申友雅思在线';

        // var_dump($data[0]);die;
        return $this->render('index', ['data'=>$data,'recommend'=>$recommend,'course'=>$course,'focus'=>$focus,'examInfo'=>$examInfo]);
    }

    /**
     * [actionDetail 考点详情]
     * @Author don
     * @Date   2021-11-01
     * @return [type]     [description]
     */
    public function actionDetail()
    {
        $urlcode=Yii::$app->request->get('city');
        $class=Yii::$app->request->get('class');

        $data=Examroom::find()->asArray()->where('urlcode="'.$urlcode.'"')->all();
        $city=$data[0]['city'];
        // 考点名称
        $title = $data[0]['name'];
        $time=time();
        $recommend = Info::find()->asArray()->where('cate=2 and pushTime<=' . $time)->orderBy('sort asc,id desc')->limit(4)->all();
        $course = Classes::find()->asArray()->limit(3)->orderBy('viewCount desc')->all();
        $focus = Recommend::find()->asArray()->where('type=2')->orderBy('sort asc,id desc')->limit(8)->all();
        $examInfo = Info::find()->asArray()->where('cate=4 and pushTime<=' . $time)->orderBy('sort asc,id desc')->limit(4)->all();

        $news = Info::find()->asArray()->where('(cate=1 or cate=2) and pushTime<='.$time)->orderBy('sort asc,id desc')->limit(4)->all();
        $jpCourse = $course;
        $this->title = '申友雅思在线_' . $title . '_雅思考点';
        $this->keywords = '雅思考试,考试指南,考点信息';
        $this->description = $title . '，雅思考点信息，考生可通过考点信息发送功能，接收到考点信息短信内容，满足考生各种阶段备考需求，只为雅思提分，申友雅思在线';
        return $this->render('detail', ['data'=>$data,'city'=>$city,'recommend'=>$recommend,'course'=>$course,'focus'=>$focus,'examInfo'=>$examInfo,'news'=>$news,'jpCourse'=>$jpCourse]);
    }

}